Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Support analyzing context receivers #1475

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

apatrida
Copy link

@apatrida apatrida commented Jul 22, 2023

Add analysis for context receivers (experimental up thought Kotlin 1.9 but should be final in Kotlin 2.0)

This basically clones code for extension receivers and adds support for context receivers in the same classes and interfaces. The testing is mirroring the same level of support for extension receivers (which is minimally covered in tests).

This is to address issue #1136

TODO:

  • constructors with context receivers
  • open questions below
  • top level functions are not currently covered by tests for Extension Receiver nor for this new context receivers, should they be?

@apatrida
Copy link
Author

Question for opinions:

A context receiver on the class level applies to the constructors, but is written at the class level. So should the context receivers be exposed in the class, or via each constructor as they would be on other member functions or top-level functions?

@apatrida
Copy link
Author

Question for opinions:

A context receiver can be on functions, methods, classes. Should they therefore be available from KSDeclaration and return emptyList for properties and typealiases, or should they bely on classes and function declarations.

@apatrida
Copy link
Author

Question to resolve:

Does https://github.com/tschuchortdev/kotlin-compile-testing have a way to set freeArgs or -Xcontext-receivers in some way for the compiler? This change here could impact that until this feature is stable and the flag is removed (Kotlin 2.0)

@apatrida
Copy link
Author

Hello, any feedback on this approach? Nearly stable release for feature in Kotlin, and this is probably pretty close to what is needed.

@Ferdia-Fagan
Copy link

I am just going to poke this because I have been waiting for this for so long ... Any success with this? or is it still in experimental?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants